// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.core.raknet;

import java.nio.ByteBuffer;

public class TestServer {
    static RakNetPeerInterface server;
    static ByteBuffer buf = ByteBuffer.allocate(2048);

    public static void main(String[] var0) {
        server = new RakNetPeerInterface();
        server.SetServerPort(12203, 12204);
        server.Init(false);
        int _int = server.Startup(32);
        System.out.println("Result: " + _int);
        server.SetMaximumIncomingConnections(32);
        server.SetOccasionalPing(true);
        server.SetIncomingPassword("spiffo");
        boolean _boolean = false;

        while (!_boolean) {
            String string = "This is a test message";
            ByteBuffer byteBuffer = Receive();
            decode(byteBuffer);
        }
    }

    private static void decode(ByteBuffer byteBuffer) {
        int int0 = byteBuffer.get() & 255;
        switch (int0) {
            case 0:
            case 1:
                System.out.println("PING");
                break;
            case 19:
                int int1 = byteBuffer.get() & 255;
                long _long = server.getGuidFromIndex(int1);
                break;
            case 21:
                System.out.println("ID_DISCONNECTION_NOTIFICATION");
                break;
            case 22:
                System.out.println("ID_CONNECTION_LOST");
                break;
            case 25:
                System.out.println("ID_INCOMPATIBLE_PROTOCOL_VERSION");
                break;
            default:
                System.out.println("Other: " + int0);
        }
    }

    public static ByteBuffer Receive() {
        int _int = buf.position();
        boolean _boolean = false;

        do {
            try {
                Thread.sleep(1L);
            } catch (InterruptedException interruptedException) {
                interruptedException.printStackTrace();
            }

            _boolean = server.Receive(buf);
        } while (!_boolean);

        return buf;
    }
}
